<?php 
defined('IN_PHPCMS')or exit('No permission resources.'); 
pc_base::load_app_class('admin','admin',0);
class upfiles{
    public $upfile = "uploadfile/system/company/"; //上传目录
  
    public $maxsize= 1024000;
    //上传方法开始
    function upfile($filename){
        $newname = date("Ymdhs").mt_rand(0,9).mt_rand(0,9).mt_rand(0,9); //使用日期做文件名
	
        $name = $_FILES[$filename]["name"];
		$type = $_FILES[$filename]["type"];
		$size = $_FILES[$filename]["size"];
		$tmp_name = $_FILES[$filename]["tmp_name"];
      
        //文件类型判断
        switch ($type) {
			case 'image/pjpeg' :
			case 'image/jpeg' :
				$extend = ".jpg";
				break;
			case 'image/gif' :
				$extend = ".gif";
				break;
			case 'image/png' :
				$extend = ".png";
				break;
		}
       
     
        $filename=$newname.$extend;
        if (move_uploaded_file($tmp_name, $this->upfile.$filename)) {
			return $filename;
		}
    }
}
 class company{ 
        function __construct() {

$this->caswee_db = pc_base::load_model('caswee_company1');
$this->caswee4_db = pc_base::load_model('caswee_company');
$this->caswee3_db = pc_base::load_model('caswee_logobuy');
			$this->caswee5_db = pc_base::load_model('caswee_product');
			$this->caswee6_db = pc_base::load_model('caswee_new');
			$this->caswee7_db = pc_base::load_model('caswee_services');
			$this->caswee8_db = pc_base::load_model('caswee_support');
			$this->caswee9_db = pc_base::load_model('caswee_contacts');
			$this->caswee1_db = pc_base::load_model('caswee_logo');
				$this->caswee2_db = pc_base::load_model('caswee_logounder');
pc_base::load_app_func('global');
  $this->_username = param::get_cookie('_username');
		}
public function init() { 
	$style=$_GET['style'];
	$lang=$_GET['lang'];
  		if($lang==cn){
			 $where=isset($_GET['style'])?"class1='$style'":null;
		
			
			 $where3="lang='cn'";
			 $page = isset($_GET['page']) && intval($_GET['page']) ? intval($_GET['page']) : 1;
			 $infos = $this->caswee_db->listinfo($where,$order = 'id DESC',$page, $pages = '12');
			 $infos1 = $this->caswee1_db->listinfo($where2,$order = 'id DESC',$page, $pages = '9');
			 $infos3 = $this->caswee3_db->listinfo($where2,$order = 'id DESC',$page, $pages = '8');
			 $infos2 = $this->caswee2_db->listinfo($where2,$order = 'id DESC',$page, $pages = '9');
			$infos4 = $this->caswee4_db->listinfo($where2,$order = 'id DESC',$page, $pages = '8');
			$infos5 = $this->caswee5_db->listinfo($where3,$order = 'id DESC',$page, $pages = '8');
			$infos6 = $this->caswee6_db->listinfo($where3,$order = 'id DESC',$page, $pages = '8');
			$infos7 = $this->caswee7_db->listinfo($where3,$order = 'id DESC',$page, $pages = '8');
			$infos8 = $this->caswee8_db->listinfo($where3,$order = 'id DESC',$page, $pages = '8');
			$infos9 = $this->caswee9_db->listinfo($where3,$order = 'id DESC',$page, $pages = '8');
		$infos10 = $this->caswee4_db->listinfo($where3,$order = 'id DESC',$page, $pages = '8');
	 $pages = $this->caswee_db->pages;
			include template('caswee_CN', 'company');}
			else{
	  $where=isset($_GET['style'])?"class1='$style'":null ;

	   $where3="lang='en'";
  		$page = isset($_GET['page']) && intval($_GET['page']) ? intval($_GET['page']) : 1;
		$infos = $this->caswee_db->listinfo($where,$order = 'id DESC',$page, $pages = '12');
		 $infos2 = $this->caswee2_db->listinfo($where2,$order = 'id DESC',$page, $pages = '9');
		$infos4 = $this->caswee4_db->listinfo($where2,$order = 'id DESC',$page, $pages = '8');
		$infos10 = $this->caswee4_db->listinfo($where3,$order = 'id DESC',$page, $pages = '8');
		$infos3 = $this->caswee3_db->listinfo($where2,$order = 'id DESC',$page, $pages = '8');
	$infos5 = $this->caswee5_db->listinfo($where3,$order = 'id DESC',$page, $pages = '8');
	$infos6 = $this->caswee6_db->listinfo($where3,$order = 'id DESC',$page, $pages = '8');
	$infos7 = $this->caswee7_db->listinfo($where3,$order = 'id DESC',$page, $pages = '8');
	$infos8 = $this->caswee8_db->listinfo($where3,$order = 'id DESC',$page, $pages = '8');
	$infos9 = $this->caswee9_db->listinfo($where3,$order = 'id DESC',$page, $pages = '8');
	$infos1 = $this->caswee1_db->listinfo($where2,$order = 'id DESC',$page, $pages = '9');
		$pages = $this->caswee_db->pages;
		$action=$_GET["action"];
			$template=company.$action;

  	
		
	
		pc_base::load_sys_class('form', '', 0);
 		include template('caswee', $template);
	}  
}
		public function delete(){
		$id=$_GET['id'];
		  	$_username=$this->_username;
	if(!$_username){
			showmessage(L('请登录后再进行操作！'),'index.php?m=member&c=index&a=login');
		}
			$this->caswee_db->delete(array('id'=>$id));
			showmessage(L('删除成功！'),'index.php?m=caswee&c=company&action=manage');


	}
	public function la(){
 	
		
 		
 		
 			$_POST['ly']['class'] =$_POST['class'];
			$_POST['ly']['link'] =$_POST['link'];
			$_POST['ly']['lang'] =$_POST['class1'];
			
			
 			
  			$this->caswee4_db->insert($_POST['ly']);
 			showmessage(L('add_success'), "?m=caswee&c=company&action=class");
 		
 
 			
 
	}
		public function lb(){
 	
		
 		
 		$id=$_POST['id'];
 			$_POST['ly']['class'] =$_POST['class'];
			$_POST['ly']['link'] =$_POST['link'];
			
			
 			
  			$this->caswee4_db->update($_POST['ly'],"id=$id");
 			showmessage(L('add_success'), "?m=caswee&c=company&action=class");
 		
 
 			
 
	}
	  public function lc(){
 	
		$img1= new upfiles();   //实例化类文件
            $photo1 = $img1->upfile("file2"); //上传的文件域
 		
 		$id=$_POST['id'];
 			$_POST['ly']['title'] =$_POST['title'];
		
			$_POST['ly']['content'] =$_POST['content'];
			$_POST['ly']['class1'] =$_POST['class1'];
			
			if(!$photo1){
 		$_POST['ly']['img']=$_POST['tupian'];
			}else{
				$_POST['ly']['img']=$photo1;}
 			
  			$this->caswee_db->update($_POST['ly'],"id=$id");
 			showmessage(L('add_success'), "?m=caswee&c=company&action=manage");
 		
 
 			
 
	}
public function ly(){
				$img= new upfiles();   //实例化类文件
            $photo = $img->upfile("file"); //上传的文件域
 	$link_db = pc_base::load_model(caswee_company1);
			$_POST['ly']['addtime'] =time();
 			$_POST['ly']['userid'] = $this->_userid;
 			$_POST['ly']['username'] = $this->_username;
 			$_POST['ly']['title'] = $_POST['title'];
			$_POST['ly']['content'] = $_POST['editor1'];
			$_POST['ly']['class1']=$_POST['class1'];
		
	
	if(!$photo){
 			$_POST['ly']['img']=$_POST['tupian'];
			}else{
				$_POST['ly']['img']=$photo;}

  			$link_db->insert($_POST['ly']);
 			showmessage(L('add_success'), "?m=caswee&c=company&action=manage");
 		
 
 			
 }

} 
?>
